package my.jypark.seminar;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 * User: jypark
 * Date: 13. 10. 29
 * Time: 오전 11:57
 * To change this template use File | Settings | File Templates.
 */
public class Attribute {
    private String name = null;
    protected byte [] data = null;

    protected LinkedList<Attribute> attrList = null;

    public Attribute(String name, DataInputStream ins) throws IOException {
        this.name = name;

        // attribute length
        int len = ins.readInt();

        if (len == 0) return;

        readData(ins, len);
    }

    public String getName() {
        return name;
    }

    public int getLen() {
        if (data == null) return 0;

        return data.length;
    }

    protected void readData(DataInputStream ins, int len) throws IOException {
        data = new byte[len];
        ins.read(data, 0, len);
    }
}